﻿@{
    ViewBag.Title = "草稿";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section HeadIncluder 
{
    <link href='@Url.Content("~/Content/public.css")'  type="text/css" rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")'  type="text/css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href=@Url.Content("~/Scripts/skins/default.css")   />
    <script type="text/javascript" src=@Url.Content("~/Scripts/lhgdialog.min.js")> </script>
}
<div class="content" onkeydown="EnterClick(event.keyCode)">
    <div class="ss_box list_tble" style="margin-top: 20px;">
        <div class="s_box1">
            <table class="s_tble ">
                <tr>
                    <td>流程标题/序号:
                        <input id="txtAppName" type="text" name="AppName" /></td>
                    <td>发送时间:<input id="txtStartDate" type="text" />到<input id="txtEndDate" type="text" />
                    </td>
                    <td><span class="btn_s btn_c1" style="margin-left: 4px;"><a href="javascript:void(0)" onclick="onRefresh()">查找</a></span></td>
                </tr>
            </table>
        </div>
    </div>
</div>
 <div id="container" style="margin-right: 10px;">
        <div id="divGrid" style="width: 100%; height: 100%;">
            <table id="grid">
                <tr>
                    <th>序号</th>
                    <th>流程名称</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </table>
            <a></a>
        </div>
    </div>

    <script id="rowTemplate" type="text/x-kendo-tmpl">
        <tr>
           <td><a href="javascript:void(0)" onclick="onProcessClick('#: ID #','#: FormAction #','#: ProccessGuid #')" >#: ID #</a></td> 
            <td><a href="javascript:void(0)" onclick="onProcessClick('#: ID #','#: FormAction #','#: ProccessGuid #')" >#: FormType #</a></td>
           <td>#: CreateTime#</td> 
            <td><a href="javascript:void(0)"  class="k-button k-button-icontext" onclick="DeleteMyDraft('#: ID #', '#: FormAction #')">删除</a></td> 
        </tr>
</script>
 <script type="text/javascript" >
     function onProcessClick(FormID, FormAction, ProccessGuid) {
         var url = '@Url.Action("ViewDraftDetail")' + "?FormID=" + FormID + "&&FormAction=" + FormAction + "&&ProccessGuid=" + ProccessGuid;
         var width = screen.availWidth * 0.8;
         var top = screen.availWidth * 0.05;
         var left = screen.availWidth * 0.1;
         var height = screen.availHeight * 0.8;
         window.open(url, "", "width=" + width + "px, height=" + height + "px, top=" + top + "px, left=" + left + "px");
     }
     function DeleteMyDraft(id, FormAction) {
         var url = '@Url.Action("DeleteMyDraft")' + '?id=' + id + "&&FormAction=" + FormAction;
         $.post(url, function (data) {
             if (data.Status == 1) {
                 onRefresh();
             } else {
                 alert("流程删除失败！请联系系统管理员");
             }
         });
     }

     function onClear() {
         $("#frm").reset();
     }
     function onRefresh() {
         var grid = $("#grid").data("kendoGrid");
         grid.dataSource.read();
     }
     function EnterClick(va) {
         if (va == 13) {
             onRefresh()
         }
     }
     function loadData() {
         $("#grid").kendoGrid({
             selectable: "multiple,row",
             dataSource: {
                 serverPaging: true,
                 pageSize: 15,
                 transport: {
                     read: {
                         url: '@Url.Action("Index")' + "?StartTime=" + $("#txtStartDate").val() + "&&EndTime=" + $("#txtEndDate").val(),
                         type: "POST",
                         dataType: "json",
                         data: {
                             dtStart: function () {
                                 return $("#txtStartDate").val();
                             },
                             dtEnd: function () {
                                 return $("#txtEndDate").val();
                             },
                             keyword: function () {
                                 return $("#txtAppName").val();
                             },
                         }
                     }
                 },
                 schema: {
                     model: {
                         fields: {
                             CreateTime: { type: "date" },
                         }
                     },
                     //取出資料陣列
                     data: function (d) { return d.Data; },
                     //取出資料總筆數(計算頁數用)
                     total: function (d) { return d.TotalCount; }
                 }
             },
             height: 600,
            
             pageable: {
                 refresh: true,
             },
             dataBinding: function (e) {
                 for (var i = 0; i < e.items.length; i++) {
                    
                     e.items[i].CreateTime = company(e.items[i].CreateTime);
                 }
             },
             rowTemplate: kendo.template($("#rowTemplate").html())
         });
     }

     $(function () {
         loadData();
         $("#txtStartDate").kendoDatePicker({ format: "yyyy-MM-dd" });
         $("#txtEndDate").kendoDatePicker({ format: "yyyy-MM-dd" });
     });
     function company(CreatedDateTime) {
         var now = new Date(CreatedDateTime);

         var year = now.getFullYear();       //年
         var month = now.getMonth() + 1;     //月
         var day = now.getDate();            //日

         var hh = now.getHours();            //时
         var mm = now.getMinutes();          //分

         var clock = year + "-";

         if (month < 10)
             clock += "0";
         clock += month + "-";

         if (day < 10)
             clock += "0";

         clock += day + " ";

         if (hh < 10)
             clock += "0";

         clock += hh + ":";
         if (mm < 10) clock += '0';
         clock += mm;
         return clock;
     }
 </script>

 